#!/usr/bin/python3
# -*- coding: UTF-8 -*-

import socket
import json

BUFSIZE = 1460

server_address = '/tmp/gpio_socket'
conf = {}

sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(server_address)

for cnt in range(4):
    conf['gpio'] = cnt
    conf['level'] = 0

    sock.sendall(json.dumps(conf).encode())
    data = sock.recv(BUFSIZE)
    print('recv from server: ', data)

sock.close()


# s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# for cnt in range(4):
#     data = 'cnt %d' % cnt
#     s.sendto(data.encode(), ('101.133.173.227', 65510))

# s.close()
